package com.project.controller;

import com.project.dto.TicketDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @title
 * @author: yuyuan
 * @date: 2020/11/30 17:25
 */
@RestController
public class MoviessController {
    @Autowired
    private RestTemplate restTemplate;

    @PostMapping("/buyTicket/{number}")
    public String buyTicket(@RequestBody TicketDTO ticketDTO, @PathVariable Integer number){
        //远程调用
        String resulte = restTemplate.postForEntity("http://localhost:8080/movies/"+number,ticketDTO,String.class).getBody();
        return resulte;
    }
}
